﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Xpom_Xpum__Integrated_Development_Environment.Model.Controls;

namespace Xpom_Xpum__Integrated_Development_Environment.View.Controls
{
    /// <summary>
    /// Interaction logic for ProjectExplorerView.xaml
    /// </summary>
    public partial class ProjectExplorerView : UserControl
    {
        #region Constructor

        public ProjectExplorerView()
        {
            InitializeComponent();
        }

        #endregion

        #region Commands

        #endregion

        #region Fields

        #endregion

        #region Properties

        #endregion

        #region Methods

        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            if ((bool)(DesignerProperties.IsInDesignModeProperty.GetMetadata(typeof(DependencyObject)).DefaultValue))
            {
            }
            else
            {
                this.DataContext = ((App)App.Current).pevm;
            }
        }

        private void treeView1_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            var item = treeView1.SelectedItem;

            if (item == null)
                return;

            var projectItem = item as ProjectItemModel;

            if (!projectItem.IsDirectory)
            {
                var oldCursor = this.Cursor;
                this.Cursor = Cursors.Wait;

                ((App)App.Current).tcvwm.LoadFile(projectItem.Path);

                this.Cursor = oldCursor;
            }
        }

        private void treeView1_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
        {

        }

        private void treeView1_SelectedItemChanged_1(object sender, RoutedPropertyChangedEventArgs<object> e)
        {
            ((App)App.Current).pevm.SelectedItem = treeView1.SelectedItem as ProjectItemModel;
        }

        #endregion
    }
}
